package com.xycake.controller.client;

import com.xycake.entity.User;
import com.xycake.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/mine")
    public Map<String,Object> xycakeHome(HttpSession httpSession){
        User loginUser = (User) httpSession.getAttribute("loginUser");
        Map<String, Object> map = new HashMap<>();
        map.put("code", 0);
        map.put("data", userService.selectAllByUser(loginUser.getUsername()));
        return map;
    }

}
